/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ms.bus.util;

import java.io.File;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import ms.dal.dao.MoviesDao;
import ms.dal.dto.Movies;

/**
 *
 * @author minh
 */
public class InitialServlet extends HttpServlet {

    @Override
    public void init() throws ServletException {
        System.out.println("********* Initial servlet success *******");
        //HibernateUtil1.getSessionFactory().getCurrentSession().beginTransaction();
        MoviesDao movieDao = new MoviesDao();
        List<Movies> movieList = movieDao.getAll();
        File movieCatalogXml = new File(getServletContext().getRealPath("/") + "xml/movies.xml");
        File movieDetailXml = new File(getServletContext().getRealPath("/") + "xml/moviesDetail.xml");
        CommonUtil.marshallMovies(movieList, movieCatalogXml);
        CommonUtil.marshallMoviesDetail(movieList, movieDetailXml);
        //HibernateUtil1.getSessionFactory().getCurrentSession().getTransaction().commit();
    }
}
